package cn.wolfcode.luowowo.airticket.service.impl;

import cn.wolfcode.luowowo.airticket.domain.FlightDestination;
import cn.wolfcode.luowowo.airticket.domain.FlightMessage;
import cn.wolfcode.luowowo.airticket.mapper.FlightMessageMapper;
import cn.wolfcode.luowowo.airticket.service.IFlightMessageService;
import com.alibaba.dubbo.config.annotation.Service;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

@Service
public class FlightMessageServiceImpl implements IFlightMessageService {

    @Autowired
    private FlightMessageMapper flightMessageMapper;

    @Override
    public List<FlightMessage> selectFlightMessage(String orgCity, String dstCity, Date deptTime) {

        List<FlightMessage> flightMessages = flightMessageMapper.selectFlightMessage(orgCity, dstCity);

        for (FlightMessage flightMessage : flightMessages) {

            if(!DateUtils.isSameDay(flightMessage.getBeginFly(),deptTime)){
                flightMessages.remove(flightMessage);
                System.out.println(flightMessages);
            }
        }

        return flightMessages;
    }
}
